package org.spring.springboot.app.agent.balancelog.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spring.springboot.app.adv.advexam.dao.AdvExamDao;
import org.spring.springboot.app.adv.advexam.domain.po.AdvExamPO;
import org.spring.springboot.app.adv.advexam.service.IAdvExamService;
import org.spring.springboot.app.agent.balancelog.dao.SysOfficeBalanceLogDao;
import org.spring.springboot.app.agent.balancelog.domain.po.SysOfficeBalanceLogPO;
import org.spring.springboot.app.agent.balancelog.domain.vo.SysOfficeBalanceLogSearchVO;
import org.spring.springboot.app.agent.balancelog.service.ISysOfficeBalanceLogService;
import org.spring.springboot.app.hard.hardinfo.domain.po.HardInfoPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysOfficeBalanceLogServiceImpl implements ISysOfficeBalanceLogService {

    private static final Logger LOGGER = LoggerFactory.getLogger(SysOfficeBalanceLogServiceImpl.class);

    @Autowired
    private SysOfficeBalanceLogDao sysOfficeBalanceLogDao;


    @Override
    public SysOfficeBalanceLogPO find(String id) {
        return sysOfficeBalanceLogDao.selectByPrimaryKey(id);
    }

    @Override
    public List<SysOfficeBalanceLogPO> findPage(SysOfficeBalanceLogSearchVO searchvo, int pageNum, int pageSize,String types) {
        return sysOfficeBalanceLogDao.findPage(searchvo,pageNum,pageSize,types);
    }

    @Override
    public int save(SysOfficeBalanceLogPO po) {
        po.preInsert();
        return sysOfficeBalanceLogDao.insertSelective(po);
    }

    @Override
    public int update(SysOfficeBalanceLogPO po) {
        po.preUpdate();
        return sysOfficeBalanceLogDao.updateByPrimaryKeySelective(po);
    }

    @Override
    public int delete(String id) {
        SysOfficeBalanceLogPO po = new SysOfficeBalanceLogPO();
        po.setId(id);
        po.preDelete();
        return sysOfficeBalanceLogDao.updateByPrimaryKeySelective(po);
    }

    @Override
    public int deletes(String ids) {
        SysOfficeBalanceLogPO record = new SysOfficeBalanceLogPO();
        String[] id_s = ids.split(",");
        record.preDelete();
        int count = 0;
        for (String id : id_s) {
            record.setId(id);
            count += sysOfficeBalanceLogDao.updateByPrimaryKeySelective(record);
        }
        return count;
    }

    @Override
    public String yesterdaySum(String officeId) {
        return sysOfficeBalanceLogDao.yesterdaySum(officeId);
    }

    @Override
    public String lastweekSum(String officeId) {
        return sysOfficeBalanceLogDao.lastweekSum(officeId);
    }

    @Override
    public String lastmonthSum(String officeId) {
        return sysOfficeBalanceLogDao.lastmonthSum(officeId);
    }

    @Override
    public List<SysOfficeBalanceLogPO> findRecen(String officeId) {
        return sysOfficeBalanceLogDao.findRecen(officeId);
    }
}
